package pat.advanced.T1003;

import java.util.*;

/**
 * @Author: 18362
 * @Create: 2022-09-09 14:05:04 星期五
 */
public class Main {

    public static int n;
    public static int m;
    public static int num;
    public static int maxWeight;
    public static int[] weight;
    public static List<int[]>[] graph;
    public static Set<Integer> vset = new HashSet<>();
    public static List<Integer>[] pre;
    public static int[] dist;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        int st = sc.nextInt();
        int ed = sc.nextInt();
        weight = new int[n];
        dist = new int[n];
        graph = new List[n];
        pre = new List[n];
        for (int i = 0; i < n; i++) {
            graph[i] = new ArrayList<>();
            pre[i] = new ArrayList<>();
        }
        for (int i = 0; i < n; i++)
            weight[i] = sc.nextInt();
        int u = 0, v = 0, l = 0;
        for (int i = 0; i < m; i++) {
            u = sc.nextInt();
            v = sc.nextInt();
            l = sc.nextInt();
            graph[u].add(new int[]{v, l});
            graph[v].add(new int[]{u, l});
        }
        dijkstra(st);
        dfs(ed, st, 0);
        System.out.println(num + " " + maxWeight);
    }

    private static void dijkstra(int st) {
        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[st] = 0;
        for (int i = 0; i < n; i++) {
            int k = -1, min = Integer.MAX_VALUE;
            for (int j = 0; j < dist.length; j++) {
                if (!vset.contains(j) && dist[j] < min) {
                    min = dist[j];
                    k = j;
                }
            }
            if (k < 0)
                break;
            vset.add(k);
            for (int j = 0; j < graph[k].size(); j++) {
                int[] pair = graph[k].get(j);
                int v = pair[0], l = pair[1];
                if (vset.contains(pair[0]))
                    continue;
                if (dist[k] + l < dist[v]) {
                    dist[v] = dist[k] + l;
                    pre[v].clear();
                    pre[v].add(k);
                } else if (dist[k] + l == dist[v]) {
                    pre[v].add(k);
                }
            }
        }
    }

    private static void dfs(int cur, int st, int sum) {
        sum += weight[cur];
        if (cur == st) {
            num++;
            maxWeight = Math.max(maxWeight, sum);
            return;
        }
        for (int i = 0; i < pre[cur].size(); i++) {
            dfs(pre[cur].get(i), st, sum);
        }
    }
}
